import {defineStore} from "pinia"
import {ref,reactive,computed} from "vue"

//组合式API写法
let useTodo=defineStore("todo",()=>{
  let arr=reactive([
    {id:1,name:'xx'},
    {id:2,name:'xxx'},
    {id:3,name:'xxxx'},
  ])
  let arr2=[1,2,3,4,5]
  function changeArr(e:any){
    arr.push(e)
  }
  let total=computed(()=>{
    return arr2.reduce((prev:number,next:number)=>{
      return prev+next
    })
  })
  return{
    arr,
    changeArr,
    total
  }
})
export default useTodo